<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>测试用页面</title>
  <script src="http://cdn.staticfile.org/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<style>
  .pre {
    display: block;
    font-family: monospace;
    white-space: pre;
  }
</style>

<body>
  <button type="button" onclick="testAxios_1()">
    Axios_get_1
  </button>
  <button type="button" onclick="testAxios_2()">
    Axios_post_2
  </button>

  <button type="button" onclick="testAjax1()">
    ajax_get
  </button>
  <button type="button" onclick="testAjax2()">
    ajax_post
  </button>
  <button type="button" onclick="testWS()">
    testWS
  </button>

</body>
<script>
  const HOST = 'http://localhost:3000/test';
  // const HOST = 'http://192.168.0.110:3000/test';

  let testAxios_1 = function () {
    axios.get(`${HOST}/MirrorForce`, {
      params: { b: 1 }
    }).then((res) => {
      console.log(res)
    })
  };
  let testAxios_2 = function () {
    axios.post(`${HOST}/MirrorForce`, {
      firstName: 'Fred',
      lastName: 'Flintstone'
    }).then((res) => {
      console.log(res)
    })
  };

  function testAjax1() {
    $.ajax({
      url: `${HOST}/MirrorForce`,
      type: 'GET',
      data: { b: 1 },

      success: function (res, status, xhr) {
        console.log(res)
        console.log(status, xhr)
      }
    })
  }
  function testAjax2() {
    $.ajax({
      url: `${HOST}/MirrorForce`,
      type: 'POST',
      data: { c: 1 },

      success: function (res, status, xhr) {
        console.log(res)
        console.log(status, xhr)
      }
    })
  }


</script>
<script>

  let ws = new WebSocket(`ws://192.168.11.50:8181`)

  ws.onmessage = function (e) {
    console.log(e)
  }
  console.log(ws)
  function testWS() {
    ws.send("<END></END>")
  }
</script>

</html>